England batsman Kevin Pietersen has been ruled out of the Cricket World Cup with a hernia operation which needs immediate attention, he said on Twitter on Monday.